<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2025/6/3
  Time: 15:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Ajax请求测试</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.js"></script>
</head>
<body>
    <input type="button" id="btn" value="ajax请求">
    <script>
        $(function () {
            $("#btn").click(function () {
                var userList = new Array();
                userList.push({
                    "name": "zhangsan",
                    "age": 18
                });
                userList.push({
                    "name": "lisi",
                    "age": 19
                });
                $.ajax({
                    url: "${pageContext.request.contextPath}/quick14",
                    type: "post",
                    dataType: "json",
                    contentType: "application/json;charset=utf-8",
                    data: JSON.stringify(userList),
                    success: function (data) {
                        alert(data);
                    },
                    error: function (data) {
                        alert("请求失败");
                    }
                })
            })
        })
    </script>
</body>
</html>
